package com.futuristik.modes;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Button;
import com.badlogic.gdx.scenes.scene2d.ui.ClickListener;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Button.ButtonStyle;
import com.badlogic.gdx.scenes.scene2d.ui.Image.Scaling;

public class MainMenu extends ArkitekMode {

	Skin skin;
	Stage ui;

	public MainMenu (Game game) {
		super(game);
	}

	@Override
	public void show () {
		
		
		ui = new Stage(480, 320, true);
		
		Image background = new Image(new TextureRegion(new Texture(Gdx.files.internal("data/background2.png"))), Scaling.none);
		background.y = 320-512;

		skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png"));
		
		//New Game Button
		//Button newGameButton = new Button("New Game", skin.getStyle(ButtonStyle.class), "button-sl");
		Button newGameButton = new Button(new Image(new TextureRegion(new Texture(Gdx.files.internal("data/menu2.png")), 22, 157, 278, 37)), new ButtonStyle());
		newGameButton.y = ui.height() - 130;
		newGameButton.x = 90;
		//newGameButton.width = 100;
		//newGameButton.height = 50;
		newGameButton.setClickListener(new ClickListener(){
			public void click(Actor actor) {
				game.setScreen(new Creation(game));
			}
		});
				
		//Load Game Button
		Button loadButton = new Button(new Image(new TextureRegion(new Texture(Gdx.files.internal("data/menu2.png")), 22, 207, 278, 37)), new ButtonStyle());
		loadButton.y = ui.height() - 180;
		loadButton.x = 90;
		loadButton.setClickListener(new ClickListener(){
			public void click(Actor actor) {
				game.setScreen(new LoadGame(game));
			}
		});
		
		//Challenge Mode Button
		Button challengeButton = new Button(new Image(new TextureRegion(new Texture(Gdx.files.internal("data/menu2.png")), 22, 283, 278, 37)), new ButtonStyle());
		challengeButton.y = ui.height() - 230;
		challengeButton.x = 90;
		challengeButton.setClickListener(new ClickListener(){
			public void click(Actor actor) {
				game.setScreen(new ChallengeMode(game));
			}
		});

		//Help Button
		Button helpButton = new Button(new Image(new TextureRegion(new Texture(Gdx.files.internal("data/menu2.png")), 22, 355, 278, 37)), new ButtonStyle());
		helpButton.y = ui.height() - 280;
		helpButton.x = 90;
		helpButton.setClickListener(new ClickListener(){
			public void click(Actor actor) {
				game.setScreen(new Help(game));
			}
		});
		
		ui.addActor(background);	
		ui.addActor(newGameButton);
		ui.addActor(loadButton);
		ui.addActor(challengeButton);
		ui.addActor(helpButton);
		
		Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
		Gdx.input.setInputProcessor(ui);	
	}
	
	@Override
	public void render (float deltaTime) {
		ui.draw();
	}

	@Override
	public void pause () {
	}

	@Override
	public void resume () {
	}

	@Override
	public void dispose () {
	}

	@Override
	public void hide () {
		ui.clear();
		ui.dispose();
	}
}
